<%@ page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>仓库管理</title>
 	<jsp:include page="/_include2/_css.jsp"/>
 
</head>
<body>
     <jsp:include page="/_include2/_menu.jsp">
		<jsp:param value="仓库管理" name="one"/>
		<jsp:param value="仓库列表" name="two"/>
	</jsp:include>
    <div class="col-md-12">
        <div class="breadcrumb" >
            <li>主页</li>
            <li>仓库管理</li>
            <li>仓库列表</li>
        </div>
       <div class="panel panel-warning">
            <div class="panel-heading">
                <h3 class="panel-title">仓库列表</h3>
            </div>
            <table class="table table-hover table-bordered">
	                <tr>
	                    
	                    <td>仓库名称</td>
	                    <td>创建时间</td>
	                    <td>总容量</td>
	                    <td>剩余容量</td>
	                    <td>备注</td>
	                    <td>仓库负责任人</td>
	                    <td>修改</td>
	                    <td>删除</td>
	                </tr>
	                <c:forEach var="store" items="${storelist}">
	                	<tr>
	                	    
	                		<td>${store.storehouse_name}</td>
	                		<td>${store.creation_date}</td>
	                		<td>${store.total_content}</td>
	                		<td>${store.residual_content}</td>
	                		<td>${store.remark}</td>
	                		<td>${store.responsible_person}</td>
	                		<td><a href="${pageContext.request.contextPath}/StoreServlet/preEdit?storehouse_id=${store.storehouse_id}" class="btn btn-link" ><span class="glyphicon glyphicon-pencil"></span>修改</a></td>	
	                   		<td><div class="btn btn-danger" onclick="deleteThis(${store.storehouse_id});"><span class="glyphicon glyphicon-remove"></span> 删除</div></td> 
	                   		
	                   		<%-- <td><div class="btn btn-danger" onclick="deleteThis(this,${store.storehouse_id});"><span class="glyphicon glyphicon-remove"></span> 删除</div></td> --%>
	                	</tr>
	                </c:forEach>
	            </table>
            </div>
        </div>
        <div id="page" style="text-align:center"></div>
    </div>
    
</body>

<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/dist/jquery-bootstrap-pagination/jquery-bootstrap-pagination.js"></script>
<script src="${pageContext.request.contextPath}/dist/layer-v3.1.1/layer/layer.js"></script>
<script type="text/javascript">
<c:if test="${deleteMessage!=null}">
alert('${deleteMessage}');
</c:if>

<c:if test="${updateMessage!=null}">
alert('${updateMessage}');
</c:if>

<%-- function deleteThis(storehouse_id){
if(confirm("确定删除吗？")){
	location="<%=request.getContextPath()%>/StoreServlet/delete?storehouse_id="+storehouse_id;
}
}
 --%>

function deleteThis(storehouse_id){
	if(confirm('确定删除此用户吗？')){
		$.get('${pageContext.request.contextPath}/StoreServlet/delete',{'storehouse_id':storehouse_id},function(data){
			if(data){
				layer.msg('删除成功');
				location.reload();	
			}else{
				layer.msg('删除失败');
			}
		});
	}
}



	// history.pushState(null,null,'http://localhost/storehouseManagement/StoreServlet/list'); 
	
	$("#page").pagination({
			  total_pages: ${pageCount},
			  current_page:${pageNum},
			  next: "下一页",
			  prev: "上一页",
			  display_max: 4,
			  callback: function(event, page) {
			    location="${ctx}/StoreServlet/listByPage?pageNum="+page;
			  }
		});
</script>


</html>